package com.wbsxch.example.springsecurity.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wbsxch.example.springsecurity.entity.User;
import com.wbsxch.example.springsecurity.service.UserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 快乐在角落里
 * @since 2019-03-05
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    //@PreAuthorize("hasAuthority('user:list')")
    @GetMapping("/")
    public String list(){
        return "user:list";
    }

    @PreAuthorize("hasAuthority('user:add')")
    @PostMapping("/")
    public String add(){
        return "user:add";
    }

    @PreAuthorize("hasAuthority('user:delete')")
    @DeleteMapping("/")
    public String delete(){
        return "user:delete";
    }

    @PreAuthorize("hasAuthority('user:update')")
    @PutMapping("/")
    public String update(){
        return "user:update";
    }
}
